$(function () {
    obj.init();
});
var obj = new function () {
    'use strict';
    return {
        form:null,
        dataGrid:null,
        staffId:null,
        init:function () {
            this.staffId = xhTool.getQuery('staffId');
            this.dataGrid = new xhDataGrid($('#list'), 'hrm/mine/getTransfer',{staffId:this.staffId});
            this.dataGrid.parseToolbar().init().activeButton(['bt_list_check'],['bt_list_del','bt_list_seeCheck']);

            this.listener();
            this.funObj().bindDgEvent();
        },
        listener:function () {
            var $this = this;
            //审批
            $('#bt_list_check').click(function () {
                if (xhExtra.buttonDisabled($(this))) {
                    return false;
                }
                $this.funObj().openCheckForm();
            });
            //删除
            $('#bt_list_del').click(function () {
                if (xhExtra.buttonDisabled($(this))) {
                    return false;
                }
                $this.funObj().delAction();
            });
            
            //搜索
            $('#bt_list_search').click(function () {
                $this.funObj().searchAction();
            });
            xhTool.bindDocKeyDown($('#bt_list_search'));
            
            $('#bt_list_seeCheck').click(function () {
                if (xhExtra.buttonDisabled($(this))) {
                    return false;
                }
                $this.funObj().checkList();
            })
        },
        funObj:function () {
            var $this = this;
            return {
                bindDgEvent:function (){
                    $this.dataGrid.onDblClickRow = function (rowIndex, rowData) {
                        // var state = $(rowData['iState']).text();
                        // if (state == '等待补充信息') {
                        //     window.top.xhTop.showModal({
                        //         title:'补充信息',
                        //         content: '<iframe src="'+moduleUrl+'mine/completeRegular?id='+rowData['iSPId']+'"  style="width: 100%;;border-style: none;padding: 0px;height: 320px"  scrolling="yes"></iframe>',
                        //         size:'lg',
                        //         extraBtn:{save:'保存'},
                        //         button:'确认',
                        //         width:900,
                        //         backClose: false
                        //     });
                        // } else {
                        //     window.top.xhTop.showModal({
                        //         title:'审核信息',
                        //         content: '<iframe src="'+moduleUrl+'mine/completeRegular?id='+rowData['iSPId']+'"  style="width: 100%;;border-style: none;padding: 0px;height: 320px"  scrolling="yes"></iframe>',
                        //         size:'lg',
                        //         width:900,
                        //         backClose: false
                        //     });
                        // }

                    }
                },
                openCheckForm:function () {
                    var iSTId = $this.dataGrid.getSelectValue('iSTId');
                    window.top.xhTop.showModal({
                        title:'转正审批',
                        content: '<iframe src="'+moduleUrl+'mine/transferCheck?id='+iSTId+'"  style="width: 100%;;border-style: none;padding: 0px;height: 220px"  scrolling="yes"></iframe>',
                        button:'通过',
                        extraBtn:{unPass:'不通过'},
                        backClose: false
                    });
                },
                delAction:function () {
                    xhExtra.askChangeStatus('',{},$this.dataGrid,function (res) {
                        window.top.xhTop.showSuccess(res.msg);
                    })
                },
                searchAction:function () {
                    $this.dataGrid.reload({
                        key:xhExtra.getValue($('#list_search')),
                        state:xhExtra.getValue($('#select_state')),
                        staffId:$this.staffId
                    })
                },
                checkList:function () {
                    var id = $this.dataGrid.getSelectValue('iSTId');
                    window.top.xhTop.showModal({
                        title:'审核历史',
                        content: '<iframe src="'+moduleUrl+'mine/checkList/transfer?id='+id+'"  style="width: 100%;;border-style: none;padding: 0px;height: 420px"  scrolling="yes"></iframe>',
                        size:'lg',
                        backClose: false
                    });
                }
            }
        }
    }
};